package com.kyh.util.smsanalysis;

import java.math.BigDecimal;

public class SmsanalysisUtil {
	
	/*
	 * 获取短信里的用户名
	 * 短信模板1---22日21:28账户*6019*网联付款收入1050.02元，余额51161.63元[兴业银行]
	 */
	public static BigDecimal getAmount(String smscontent) {
		
		String amountStr = "";
		
		// 兴业银行模板1
		if (smscontent.contains("[兴业银行]")) {
			String amountStrBefor = "网联付款收入";
			String amountStrAfter = "元，余额";
			int indexAmountBegin = smscontent.indexOf(amountStrBefor) + amountStrBefor.length();
			int indexAmountEnd = smscontent.indexOf(amountStrAfter);
			System.out.println(indexAmountBegin);
			System.out.println(indexAmountEnd);
			System.out.println(smscontent.substring(indexAmountBegin, indexAmountEnd));
			
			amountStr = smscontent.substring(indexAmountBegin, indexAmountEnd);
		}
		
		System.out.println("解析出来的金额=====" + amountStr);
		
		if (amountStr != null) {
			return new BigDecimal(amountStr);
		}
		return null;
	}
	
	public static void main(String[] args) {
		String smscontent = "22日21:28账户*6019*网联付款收入10.00元，余额11.00元[兴业银行]";
		
		System.out.println(SmsanalysisUtil.getAmount(smscontent));
	}
}
